package com.g8.pethospitallearnbackend.mapper;

import com.g8.pethospitallearnbackend.entity.Question;
import com.g8.pethospitallearnbackend.entity.QuestionExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface QuestionMapper {
    @SelectProvider(type=QuestionSqlProvider.class, method="countByExample")
    long countByExample(QuestionExample example);

    @DeleteProvider(type=QuestionSqlProvider.class, method="deleteByExample")
    int deleteByExample(QuestionExample example);

    @Delete({
        "delete from question",
        "where ques_id = #{quesId,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String quesId);

    @Insert({
        "insert into question (ques_id, ques_ans, ",
        "type_name, is_single, ",
        "ques_desc, ques_op_a, ",
        "ques_op_b, ques_op_c, ",
        "ques_op_d)",
        "values (#{quesId,jdbcType=VARCHAR}, #{quesAns,jdbcType=VARCHAR}, ",
        "#{typeName,jdbcType=VARCHAR}, #{isSingle,jdbcType=TINYINT}, ",
        "#{quesDesc,jdbcType=LONGVARCHAR}, #{quesOpA,jdbcType=LONGVARCHAR}, ",
        "#{quesOpB,jdbcType=LONGVARCHAR}, #{quesOpC,jdbcType=LONGVARCHAR}, ",
        "#{quesOpD,jdbcType=LONGVARCHAR})"
    })
    int insert(Question record);

    @InsertProvider(type=QuestionSqlProvider.class, method="insertSelective")
    int insertSelective(Question record);

    @SelectProvider(type=QuestionSqlProvider.class, method="selectByExampleWithBLOBs")
    @Results({
        @Result(column="ques_id", property="quesId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="ques_ans", property="quesAns", jdbcType=JdbcType.VARCHAR),
        @Result(column="type_name", property="typeName", jdbcType=JdbcType.VARCHAR),
        @Result(column="is_single", property="isSingle", jdbcType=JdbcType.TINYINT),
        @Result(column="ques_desc", property="quesDesc", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="ques_op_a", property="quesOpA", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="ques_op_b", property="quesOpB", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="ques_op_c", property="quesOpC", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="ques_op_d", property="quesOpD", jdbcType=JdbcType.LONGVARCHAR)
    })
    List<Question> selectByExampleWithBLOBs(QuestionExample example);

    @SelectProvider(type=QuestionSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="ques_id", property="quesId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="ques_ans", property="quesAns", jdbcType=JdbcType.VARCHAR),
        @Result(column="type_name", property="typeName", jdbcType=JdbcType.VARCHAR),
        @Result(column="is_single", property="isSingle", jdbcType=JdbcType.TINYINT)
    })
    List<Question> selectByExample(QuestionExample example);

    @Select({
        "select",
        "ques_id, ques_ans, type_name, is_single, ques_desc, ques_op_a, ques_op_b, ques_op_c, ",
        "ques_op_d",
        "from question",
        "where ques_id = #{quesId,jdbcType=VARCHAR}"
    })
    @Results({
        @Result(column="ques_id", property="quesId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="ques_ans", property="quesAns", jdbcType=JdbcType.VARCHAR),
        @Result(column="type_name", property="typeName", jdbcType=JdbcType.VARCHAR),
        @Result(column="is_single", property="isSingle", jdbcType=JdbcType.TINYINT),
        @Result(column="ques_desc", property="quesDesc", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="ques_op_a", property="quesOpA", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="ques_op_b", property="quesOpB", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="ques_op_c", property="quesOpC", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="ques_op_d", property="quesOpD", jdbcType=JdbcType.LONGVARCHAR)
    })
    Question selectByPrimaryKey(String quesId);

    @UpdateProvider(type=QuestionSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Question record, @Param("example") QuestionExample example);

    @UpdateProvider(type=QuestionSqlProvider.class, method="updateByExampleWithBLOBs")
    int updateByExampleWithBLOBs(@Param("record") Question record, @Param("example") QuestionExample example);

    @UpdateProvider(type=QuestionSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") Question record, @Param("example") QuestionExample example);

    @UpdateProvider(type=QuestionSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Question record);

    @Update({
        "update question",
        "set ques_ans = #{quesAns,jdbcType=VARCHAR},",
          "type_name = #{typeName,jdbcType=VARCHAR},",
          "is_single = #{isSingle,jdbcType=TINYINT},",
          "ques_desc = #{quesDesc,jdbcType=LONGVARCHAR},",
          "ques_op_a = #{quesOpA,jdbcType=LONGVARCHAR},",
          "ques_op_b = #{quesOpB,jdbcType=LONGVARCHAR},",
          "ques_op_c = #{quesOpC,jdbcType=LONGVARCHAR},",
          "ques_op_d = #{quesOpD,jdbcType=LONGVARCHAR}",
        "where ques_id = #{quesId,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKeyWithBLOBs(Question record);

    @Update({
        "update question",
        "set ques_ans = #{quesAns,jdbcType=VARCHAR},",
          "type_name = #{typeName,jdbcType=VARCHAR},",
          "is_single = #{isSingle,jdbcType=TINYINT}",
        "where ques_id = #{quesId,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(Question record);
}